﻿CREATE VIEW dbo.v_TruthInLending_10
AS
SELECT     BO.LoanID, BO.DealerID, BO.DealerSalesPersonID, BO.StatusID, BO.Status, BO.VerificationStatusID, BO.Status_Verification, BO.ContractHolderID, 
                      BO.SalesPrice, BO.VIN, BO.BookValue, BO.BookValueDesc, BO.ModelAge, BO.Mileage, BO.MilesPerYear, BO.SalesTaxPercent, 
                      BO.Lamp_SalesTaxPercent, BO.Lamp_SalesTaxAmount, BO.DownPayment, BO.DealerFee, BO.TaxableFees, BO.TradeIn, BO.UnpaidBalance, BO.GAP, 
                      BO.ServiceContract, BO.NonTaxableFees, BO.TagFee, BO.APROverride, BO.LoanTerm, BO.ContractDate, BO.FirstPaymentDate, 
                      BO.AddOnRateOverride, BO.PaymentOverride, BO.NumberOfPayments, BO.IsRule78, BO.IsSUV, BO.TrackerTypeID, BO.SalesTaxAmount, 
                      BO.UnPaidBalanceWithTax, BO.Lamp_UnPaidBalanceWithTax, BO.AmountFinanced, dbo.PMT_New(BO.AmountFinanced, BO.NumberOfPayments, 
                      BO.APROverride, BO.PaymentsPerYear) AS PaymentStartByAPR, CONVERT(money, dbo.RATExByAfPmt(BO.AmountFinanced, BO.PaymentOverride, 
                      BO.LoanTerm, BO.ContractDate, BO.FirstPaymentDate, BO.PaymentsPerYear, BO.DayCountConventionID) * 100) AS APRByPayment, 
                      dbo.ShowFlag(BO.PaymentOverride) AS PaymentOverrideFlag, dbo.ShowFlag(BO.APROverride) AS APROverrideFlag, BO.IsIndependent, 
                      BO.PaymentsPerYear, BO.InterestType, BO.PaymentTypeID, IT.Name AS InterestTypeName, LPT.Code AS PaymentTypeCode, 
                      BO.DayCountConventionID, BO.PrincipalBalance, BO.BookValueCurrent, BO.BookValueCurrentTypeID, CBP_VT.Description AS BookValueCurrentDesc, 
                      BO.LoanState, BO.CarYear, BO.GUID_Documents, BO.StatusID_Repo, BO.StatusUser_Repo, BO.StatusDate_Repo, BO.Status_Repo, BO.StatusID_BK, 
                      BO.StatusUser_BK, BO.StatusDate_BK, BookValueCurrentDate, BookValueProviderCode

FROM         dbo.v_BuyersOrder AS BO INNER JOIN
                      dbo.ts_InterestType AS IT ON BO.InterestType = IT.ID INNER JOIN
                      dbo.ts_LoanPaymentType AS LPT ON BO.PaymentTypeID = LPT.ID INNER JOIN
                      dbo.v_CarBookProvider_ValueType AS CBP_VT ON BO.BookValueCurrentTypeID = CBP_VT.ID


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1[50] 4[25] 3) )"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4[30] 2[40] 3) )"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4[50] 3) )"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1[47] 4) )"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4) )"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "IT"
            Begin Extent = 
               Top = 6
               Left = 297
               Bottom = 84
               Right = 448
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "LPT"
            Begin Extent = 
               Top = 6
               Left = 486
               Bottom = 114
               Right = 651
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "CBP_VT"
            Begin Extent = 
               Top = 211
               Left = 445
               Bottom = 434
               Right = 596
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "BO"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 540
               Right = 259
            End
            DisplayFlags = 280
            TopColumn = 27
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 57
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TruthInLending_10';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 6330
         Alias = 2415
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TruthInLending_10';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TruthInLending_10';

